package com.logistics.log.entity.model;

import com.logistics.log.entity.domain.Log;
import com.logistics.utils.aspect.annotation.Dictionary;
import com.logistics.utils.tool.DateUtils;
import lombok.Data;

@Data
public class LogRow {

    private int id;
    private String businessName;
    private String method;
    private String methodName;
    private String context;
    private String status;
    @Dictionary(key = "logger_type")
    private String type;
    private String requestAddress;
    private String requestMethod;
    private String parameter;
    private String createOrgCode;
    private String createDepCode;
    private String creator;
    private String createTime;
    private String updater;
    private String updateTime;

    public LogRow(){

    }

    public LogRow(Log log){
        this.id = log.getId();
        this.businessName = log.getBusinessName();
        this.method = log.getMethod();
        this.methodName = log.getMethodName();
        this.context = log.getContext();
        this.status = log.getStatus();
        this.type = log.getType();
        this.requestAddress = log.getRequestAddress();
        this.requestMethod = log.getRequestMethod();
        this.parameter = log.getParameter();
        this.createOrgCode = log.getCreateOrgCode();
        this.createDepCode = log.getCreateDepCode();
        this.creator = log.getCreator();
        this.createTime = DateUtils.dateToStringFormat(log.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
        this.updater = log.getUpdater();
        this.updateTime = DateUtils.dateToStringFormat(log.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
    }

    public static LogRow build(Log log){
        return new LogRow(log);
    }

}
